<!DOCTYPE html>
<html>
<div id="jmsCfg" class="portlet-body form">
  <div class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">基本配置</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">字符集编码</label>
      <div class="col-sm-8">
        <select name="charset" field="charset" required class="form-control select2">
          <option value="UTF-8">UTF-8编码</option>
          <option value="GBK">GBK编码</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">是否启用</label>
      <div class="col-sm-8">
        <select name="enable" field="enable" required class="form-control select2">
          <option value="true">是</option>
          <option value="false">否</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">ip</label>
      <div class="col-sm-8">
        <input id="ip_txt" name="ip" field="ip" type="text" class="form-control" required/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">端口号</label>
      <div class="col-sm-8">
        <input id="port_txt" name="port" field="port" type="number" min="1" max="65535" class="form-control" required/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">通道名称</label>
      <div class="col-sm-8">
        <input id="channel_txt" name="channel" field="channel" type="text" class="form-control" required/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">队列管理器名称</label>
      <div class="col-sm-8">
        <input id="queueManager_txt" name="queueManager" field="queueManager" type="text" class="form-control" required/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4" id="sendQueueName_title">发送队列</label>
      <div class="col-sm-8">
        <input id="sendQueueName_txt" name="sendQueueName" field="sendQueueName" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4" id="receiveQueueName_title">接收队列</label>
      <div class="col-sm-8">
        <input id="receiveQueueName_txt" name="receiveQueueName" field="receiveQueueName" type="text"
               class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4" id="receiveTimeout_title">接收超时时间(秒)</label>
      <div class="col-sm-8">
        <input id="receiveTimeout_txt" name="receiveTimeout" field="receiveTimeout" value="30" type="digits"
               class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">消息周期(秒)</label>
      <div class="col-sm-8">
        <input id="msgTimeout_txt" name="msgTimeout" field="msgTimeout" value="0" type="digits" class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">最大连接</label>
      <div class="col-sm-8">
        <input id="maxConnections_txt" name="maxConnections" field="maxConnections" value="50" type="digits"
               class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">CCSID</label>
      <div class="col-sm-8">
        <input id="fileDir_txt" name="ccsid" field="ccsid" value="819" type="digits" class="form-control"/>
      </div>
    </div>

  </div>

  <div id="threadPool_div" class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">线程池配置</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">最大线程数</label>
      <div class="col-sm-8">
        <input id="maxSize_txt" name="maxSize" field="maxSize" type="number" min="1" required class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">核心线程数</label>
      <div class="col-sm-8">
        <input id="coreSize_txt" name="coreSize" field="coreSize" type="number" min="1" required class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">缓冲队列大小</label>
      <div class="col-sm-8">
        <input id="capacity_txt" name="capacity" field="capacity" type="number" min="1" required class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">空闲线程存活时间(秒)</label>
      <div class="col-sm-8">
        <input id="aliveTime_txt" name="aliveTime" field="aliveTime" type="number" min="1" required
               class="form-control"/>
      </div>
    </div>
  </div>

  <div id="out_extcall_div" class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">配置三方插件</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">插件类</label>
      <div class="col-sm-8">
        <input id="exterClass_txt" name="exterClass" field="exterClass" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">报文与通讯函数</label>
      <div class="col-sm-8">
        <input id="externPackAndSend_txt" name="externPackAndSend" field="externPackAndSend" type="text"
               class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">组包函数</label>
      <div class="col-sm-8">
        <input id="externPack_txt" name="externPack" field="externPack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包函数</label>
      <div class="col-sm-8">
        <input id="externUnpack_txt" name="externUnpack" field="externUnpack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">通讯函数<span class="required"></span></label>
      <div class="col-sm-8">
        <input id="externSend_txt" name="externSend" field="externSend" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">组包前处理</label>
      <div class="col-sm-8">
        <input id="beforePack_txt" name="beforePack" field="beforePack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">发送前请求处理</label>
      <div class="col-sm-8">
        <input id="beforeSend_txt" name="beforeSend" field="beforeSend" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包前处理</label>
      <div class="col-sm-8">
        <input id="beforeUnpack_txt" name="beforeUnpack" field="beforeUnpack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包后处理</label>
      <div class="col-sm-8">
        <input id="beforeReturn_txt" name="beforeReturn" field="beforeReturn" type="text" class="form-control"/>
      </div>
    </div>
  </div>
</div>
<script>
  $(function () {
    //根据类型初始化页面元素
    initDom();
    // var flag = com_action_flag;
    // if (flag == "add") {
    //   var temp_ip = [[${ip}]];
    //   if (temp_ip != "" && null != temp_ip) {
    //     swal({
    //       title: "你加载的配置已经存在，确认需要修改吗？",
    //       text: "",
    //       type: "warning",
    //       showCancelButton: true,
    //       cancelButtonText: "取消",
    //       closeOnConfirm: true,
    //       confirmButtonText: "确定"
    //     }, function (isConfirm) {
    //       if (!isConfirm) {
    //         $("#packet_context_div").empty();
    //         $("#comm_cfg_form").hide();
    //       }
    //     });
    //   }
    // }


  });

  //根据类型初始化页面元素
  function initDom() {
    // var type = [[${type}]];
    // if("IN"==type){
    // 	$("#jms_out_div").hide();
    // 	$("#jms_in_div").show();
    // 	$("#threadPool_div").show();
    // 	$("#out_extcall_div").remove();
    // }else if ("OUT"==type){
    // 	$("#jms_out_div").show();
    // 	$("#jms_in_div").hide();
    // 	$("#threadPool_div").hide();
    // 	$("#out_extcall_div").show();
    // }
    if ($("#commType").val() == "IN") {
      $("#out_extcall_div").remove();
      //$("#receiveTimeout_title").remove();
      //$("#receiveTimeout_txt").parent().remove();
    } else if ($("#commType").val() == "OUT") {
      $("#out_extcall_div").show();
      //接出不展示连接池
      $("#threadPool_div").remove();
    }
    initSendRecv();
  }

  function initSendRecv() {
    var commType = $("#commType").val();
    if ("IN" == commType) {
      //接入时接受队列必填
      $("#receiveQueueName_title").addClass('is-required')
      // $("#receiveQueueName_title").html("接收队列<span class='required'> * </span>");
      // $("#receiveQueueName_txt").rules("add", {required: true, checkInput: true});
      // $("#sendQueueName_txt").rules("remove");
    } else if ("OUT" == commType) {
      //接出时发送队列必填
      $("#sendQueueName_title").addClass('is-required')
      // $("#sendQueueName_title").html("发送队列<span class='required'> * </span>");
      // $("#sendQueueName_txt").rules("add", {required: true, checkInput: true});
      // $("#receiveQueueName_txt").rules("remove");
    }
  }

</script>